package com.axcbd.demo.controller;

import com.axcbd.demo.dto.response.ApiResponse;
import com.axcbd.demo.model.Humidity;
import com.axcbd.demo.service.HumidityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/humidity")
public class HumidityController {

    @Autowired
    private HumidityService  humidityService;


    @GetMapping("/latest/{n}")
    public ResponseEntity<ApiResponse<?>> getLatestNHumidity(@PathVariable int n){
        List<Humidity> list = humidityService.getLatestNHumidity(n);
        return ResponseEntity.ok(new ApiResponse<>(list));
    }


}
